﻿using General.Core;
using General.Framework.Filters;
using General.Framework.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text;

namespace General.Framework.Controllers.Admin
{
    /// <summary>
    /// 
    /// </summary>
    [AdminAuth]
    public class PublicAdminController : AdminAreaController
    {
        private IWorkContext _workContext;

        public IWorkContext WorkContext => _workContext;

        public PublicAdminController()
        {
            _workContext = EngineContext.Current.Resolve<IWorkContext>();
        }



        /// <summary>
        /// 处理结果返回json
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        protected IActionResult ReturnJson((bool Status,string Message) result)
        {
            AjaxData.Status = result.Status;
            AjaxData.Message = result.Message;
            return Json(result);
        }

        /// <summary>
        /// 验证不通过返回json
        /// </summary>
        /// <returns></returns>
        protected IActionResult ReturnValid()
        {
            AjaxData.Status = false;
            AjaxData.Message = ModelState.GetErrMsg();
            return Json(AjaxData);
        }

    }


}
